package com.example.locationreport.locationreport.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.example.locationreport.locationreport.global.Constant;
import com.example.locationreport.locationreport.utils.LogLocationUtils;


/**
 * 消息广播监听
 */
public abstract class CommonReceiver extends BroadcastReceiver {
    private static final String TAG = CommonReceiver.class.getSimpleName();
    @Override
    public void onReceive(Context context, Intent intent) {
        switch (intent.getAction()) {
            case Constant.ReceiverSpeak:
                // 消息
                initSpeak();
                break;
            case Constant.ReceiverOnlineLocation:
                if (Constant.RK_INF.equals(intent.getStringExtra(Constant.TYPE))) {
                    // 在线消息
                    initOnlineLocation();
                } else if (Constant.OTHER_INF.equals(intent.getStringExtra(Constant.TYPE))) {
                    initOnlineOther();
                }
                break;
            case Constant.CONFIGURATION_CHANGED:
                LogLocationUtils.writeLog(TAG, "CommonReceiver已接收到：android.intent.action.CONFIGURATION_CHANGED 广播");
                initActivityMethod();//接收系统CONFIGURATION_CHANGED广播
                break;
        }
    }

    public abstract void initSpeak();

    public abstract void initOnlineLocation();

    public abstract void initOnlineOther();

    public abstract void initActivityMethod();
}
